import axios from "axios";
interface ptype {
  startNum?: number;
  pageSize?: number;
}

const inst = axios.create({
  baseURL: "http://localhost:3000", // 替换为实际的 API 基础 URL
  timeout: 5000, // 超时时间设置为 5 秒，可按需调整
});
// inst.interceptors.response.use((resp: any) => resp);相应拦截

const get = (url: string, params: any = "") => {
  return new Promise((resolve, reject) => {
    inst.get(url, params as any).then((res: any) => {
      if (res.status === 200) {
        resolve(res.data);
      }
    });
  });
};
const post = (url: string, params: any="") => {
  return new Promise((resolve, reject) => {
    inst.post(url, params as any).then((res: any) => {
      if (res.code === 200) {
        resolve(res);
      }
    });
  });
};
// export function getFeedList(params: ptype) {
//   return get("/feeds", { params } as any);
// }

export {
  get,
  post
}